package com.txunda.zhuohired.aty.manage.home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.aty.user.find.ShareAty;
import com.txunda.zhuohired.base.BaseAty;
import com.txunda.zhuohired.view.TagCloudView2;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/10 17:42
 * 功能描述：全职职位详情
 * 联系方式：jiahuanchen@126.com
 */

public class ManageAllDetailsAty extends BaseAty {
    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_manage_all_details_center)
    private TextView tv_layout_manage_all_details_center;
    /**
     * 公司福利
     */
    @ViewInject(R.id.tag_manage_all_details)
    private TagCloudView2 tag_manage_all_details;
    /**
     * 关闭职位
     */
    @ViewInject(R.id.tv_manage_all_details_close)
    private TextView tv_manage_all_details_close;
    /**
     * 审核中
     */
    @ViewInject(R.id.tv_manage_all_details_bottom)
    private TextView tv_manage_all_details_bottom;


    private List<String> welfareList;
    private String[] welfareStr = {"每周双休", "班车接送", "五险一金", "定期团建", "年终奖", "朝九晚八"};

    private String type = "";


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_manage_all_details_head);
        tv_layout_manage_all_details_center.setText("职位详情");
    }

    @Override
    @OnClick({R.id.tv_manage_all_details_bottom, R.id.iv_layout_manage_all_details_share})
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_manage_all_details_bottom://重新发布
                startActivity(PostJobAty.class, null);
                break;
            case R.id.iv_layout_manage_all_details_share://分享
                startActivity(ShareAty.class, null);
                break;
        }
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_manage_all_details;
    }

    @Override
    protected void initialized() {
        type = getIntent().getStringExtra("type");
        welfareList = new ArrayList<>();
        for (int i = 0; i < welfareStr.length; i++) {
            welfareList.add(welfareStr[i]);
        }
    }

    @Override
    protected void requestData() {
        tag_manage_all_details.setTags(welfareList);
        initData();
    }

    private void initData() {
        if ("0".equals(type)) {
            tv_manage_all_details_close.setVisibility(View.VISIBLE);
            tv_manage_all_details_close.setText("关闭职位");
            tv_manage_all_details_bottom.setVisibility(View.GONE);
        } else if ("1".equals(type)) {
            tv_manage_all_details_close.setVisibility(View.VISIBLE);
            tv_manage_all_details_close.setText("已关闭");
            tv_manage_all_details_bottom.setVisibility(View.GONE);
        } else if ("3".equals(type)) {
            tv_manage_all_details_close.setVisibility(View.GONE);
            tv_manage_all_details_bottom.setVisibility(View.VISIBLE);
            tv_manage_all_details_bottom.setText("发布职位，正在审核中~");
        } else if ("4".equals(type)) {
            tv_manage_all_details_close.setVisibility(View.GONE);
            tv_manage_all_details_bottom.setVisibility(View.VISIBLE);
            tv_manage_all_details_bottom.setText("审核失败，请从新发布!");
        } else {
            tv_manage_all_details_close.setVisibility(View.VISIBLE);
            tv_manage_all_details_close.setText("关闭职位");
            tv_manage_all_details_bottom.setVisibility(View.GONE);
        }
    }
}
